package com.hmdp.utils;

import com.hmdp.dto.*;
import org.springframework.web.servlet.*;

import javax.servlet.http.*;

public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        if(UserHolder.getUser() == null){
              //4.不存在，拦截，返回401状态码
              response.setStatus(401);
              return false;
        }
        //放行
        return true;
    }
}